/**
 * Created by three on 14-11-4.
 */
'use strict';

(function (app) {
    app.controller('LangController', ['$scope', function ($scope) {
        /*$scope.languages = settings.languages;
         $scope.currentLang = settings.currentLang;
         $scope.setLang = function (lang) {
         settings.currentLang = lang;
         $scope.currentLang = lang;
         localize.setLang(lang);
         };

         // set the default language
         $scope.setLang($scope.currentLang);*/
        $scope.languages = [{}];

    }])
        .controller('LeftPanelCtrl', ['$scope','logger','config',
            function ($scope, logger, config) {

                $scope.$emit('loading', {
                    type: 'LoadingModal',
                    data: {
                        msg: '正在拼命加载，请稍后...'
                    }
                });
                $scope.menuList = [];
                config.asyncData.menuData.then(function (data) {
                    logger.log(data)
                    $scope.menuList.push(
                        {'name': 'demo', 'url': '', 'title': '演示', 'icon': 'fa fa-lg fa-fw fa-table',
                            'items': [
                                {'name': 'Dashboard', 'url': '/app/demo/dashboard', 'title': '仪表盘', 'icon': 'fa fa-lg fa-fw fa-home'},
                                {'name': 'date', 'url': '/app/demo/date', 'title': 'dateCtrl', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'editor', 'url': '/app/demo/editor', 'title': '编辑框', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'tree', 'url': '/app/demo/tree', 'title': '树视图', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'ztree', 'url': '/app/demo/ztree', 'title': 'ztree视图', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'datagrid', 'url': '/app/demo/datagrid', 'title': '数据表格', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'allcharts', 'url': '', 'title': '各种图表', 'icon': 'fa fa-lg fa-fw fa-table',
                                    items: [
                                        {'name': 'charts', 'url': '/app/demo/charts', 'title': 'echart图表控件', 'icon': 'fa fa-lg fa-fw fa-table'},
                                        {'name': 'plantuml', 'url': '/app/demo/plantuml', 'title': 'plantuml图', 'icon': 'fa fa-lg fa-fw fa-table'}
                                    ]
                                },
                                {'name': 'fileupload', 'url': '/app/demo/fileupload', 'title': '图片/文件上传', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'socketio', 'url': '/app/demo/socketio', 'title': 'socket.io', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'animate', 'url': '/app/demo/animate', 'title': 'angular-animate', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'pagination', 'url': '/app/demo/pagination', 'title': '分页控件', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'ui-bootstrap', 'url': '/app/demo/ui-bootstrap', 'title': 'angular-ui-bootstrap', 'icon': 'fa fa-lg fa-fw fa-table'}
                            ]
                        });
                    $scope.$emit('loading', {
                        type: 'LoadedModal'
                    });
                }, function (err) {
                    $scope.menuList.push(
                        {'name': 'demo', 'url': '', 'title': '演示', 'icon': 'fa fa-lg fa-fw fa-table',
                            'items': [
                                {'name': 'Dashboard', 'url': '/app/demo/dashboard', 'title': '仪表盘', 'icon': 'fa fa-lg fa-fw fa-home'},
                                {'name': 'date', 'url': '/app/demo/date', 'title': 'dateCtrl', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'editor', 'url': '/app/demo/editor', 'title': '编辑框', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'tree', 'url': '/app/demo/tree', 'title': '树视图', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'ztree', 'url': '/app/demo/ztree', 'title': 'ztree视图', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'datagrid', 'url': '/app/demo/datagrid', 'title': '数据表格', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'allcharts', 'url': '', 'title': '各种图表', 'icon': 'fa fa-lg fa-fw fa-table',
                                    items: [
                                        {'name': 'charts', 'url': '/app/demo/charts', 'title': 'echart图表控件', 'icon': 'fa fa-lg fa-fw fa-table'},
                                        {'name': 'plantuml', 'url': '/app/demo/plantuml', 'title': 'plantuml图', 'icon': 'fa fa-lg fa-fw fa-table'}
                                    ]
                                },
                                {'name': 'fileupload', 'url': '/app/demo/fileupload', 'title': '图片/文件上传', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'socketio', 'url': '/app/demo/socketio', 'title': 'socket.io', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'animate', 'url': '/app/demo/animate', 'title': 'angular-animate', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'pagination', 'url': '/app/demo/pagination', 'title': '分页控件', 'icon': 'fa fa-lg fa-fw fa-table'},
                                {'name': 'ui-bootstrap', 'url': '/app/demo/ui-bootstrap', 'title': 'angular-ui-bootstrap', 'icon': 'fa fa-lg fa-fw fa-table'}
                            ]
                        });
                    $scope.$emit('loading', {
                        type: 'LoadedModal'
                    });
                    logger.log(err)
                }, function (loading) {
                    logger.log(loading)
                });
            }])
        .controller('ActivityNotifyCtrl', ['$scope', function ($scope) {
            var ctrl = this;
            ctrl.getDate = function () {
                return new Date().toUTCString();
            };

            $scope.refreshCallback = function (contentScope, done) {

                // use contentScope to get access with activityContent directive's Control Scope
                console.log(contentScope);

                // for example getting your very long data ...........
                setTimeout(function () {
                    done();
                }, 3000);

                $scope.footerContent = ctrl.getDate();
            };

            $scope.items = [
                {'title': 'Msgs', 'count': 4, 'src': '/app/demo/animate'},
                {'title': 'Notify', 'count': 4, 'src': '/app/demo/animate'},
                {'title': 'Tasks', 'count': 4, 'src': '/app/demo/animate'},
                {'title': 'animate', 'count': 4, 'src': 'scripts/func/demo/template/animate.html'}
            ];//MessageService.query();
            $scope.total = 0;
            angular.forEach($scope.items, function (item) {
                $scope.total += item.count;
            });

            $scope.footerContent = ctrl.getDate();

        }])
}(app));
